﻿using AdminManager.Localization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;

namespace AdminManager.Permissions;

public class AdminManagerPermissionDefinitionProvider : PermissionDefinitionProvider
{
    public override void Define(IPermissionDefinitionContext context)
    {
        //var myGroup = context.AddGroup(AdminManagerPermissions.GroupName);
        //Define your own permissions here. Example:
        //myGroup.AddPermission(AdminManagerPermissions.MyPermission1, L("Permission:MyPermission1"));
        var systemGroup = context.AddGroup(AdminManagerPermissions.GroupName, L("Permission:SystemManagement"));
        
        var navigationsPermission = systemGroup.AddPermission(AdminManagerPermissions.Navigations.Default, L("Permission:NavigationManagement"));
        navigationsPermission.AddChild(AdminManagerPermissions.Navigations.Create, L("Permission:Create"));
        navigationsPermission.AddChild(AdminManagerPermissions.Navigations.Update, L("Permission.Edit"));
        navigationsPermission.AddChild(AdminManagerPermissions.Navigations.Delete, L("Permission.Delete"));

        var securityLogsPermission = systemGroup.AddPermission(AdminManagerPermissions.SecurityLogs.Default,L("Permission:SecurityLogManagement"));
        securityLogsPermission.AddChild(AdminManagerPermissions.SecurityLogs.Create, L("Permission:Create"));
        securityLogsPermission.AddChild(AdminManagerPermissions.SecurityLogs.Update, L("Permission.Edit"));
        securityLogsPermission.AddChild(AdminManagerPermissions.SecurityLogs.Delete, L("Permission.Delete"));


        var auditLogsPermission = systemGroup.AddPermission(AdminManagerPermissions.AuditLogs.Default, L("Permission:AuditLogManagement"));
        auditLogsPermission.AddChild(AdminManagerPermissions.AuditLogs.Create, L("Permission:Create"));
        auditLogsPermission.AddChild(AdminManagerPermissions.AuditLogs.Update, L("Permission.Edit"));
        auditLogsPermission.AddChild(AdminManagerPermissions.AuditLogs.Delete, L("Permission.Delete"));

        var organizationUnitsPermission = systemGroup.AddPermission(AdminManagerPermissions.OrganizationUnits.Default, L("Permission:OrganizationUnitManagement"));
        organizationUnitsPermission.AddChild(AdminManagerPermissions.OrganizationUnits.Create, L("Permission:Create"));
        organizationUnitsPermission.AddChild(AdminManagerPermissions.OrganizationUnits.Update, L("Permission.Edit"));
        organizationUnitsPermission.AddChild(AdminManagerPermissions.OrganizationUnits.Delete, L("Permission.Delete"));

    }

    private static LocalizableString L(string name)
    {
        return LocalizableString.Create<AdminManagerResource>(name);
    }
}
